/*
** var.hh
** Login : <David@sandrock.lrde.epita.fr>
** Started on  Mon Apr  7 13:41:39 2003 David Lesage
** $Id: initializer.hh 46 2003-04-13 17:36:47Z burrus_n $
** 
** Copyright (C) 2003 David Lesage
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
** 
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.
** 
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

#ifndef   	INITIALIZER_HH_
# define   	INITIALIZER_HH_

# include <list>

namespace evz
{

  /*------------.
  | Initializer |
  `------------*/

  //! Create a list of elements on the fly.
  /*! 
    This class is really useful to initialize data structures with
    list of elements.
  */

  template <class T>
  class Initializer
  {
  public:
    typedef std::list<T> list_type;
    typedef typename list_type::const_iterator const_iterator;

  public:
    // Iterator proxies.
    const_iterator begin() const
    {
      return elts_.begin();
    }

    const_iterator end() const
    {
      return elts_.end();
    }

  public:
    Initializer<T>& operator,(T t)
    {
      elts_.push_back(t);
      return *this;
    }

    const list_type& get_elts() const
    {
      return elts_;
    }

  private:
    list_type elts_;
  };

} // end of evz

#endif	    /* !INITIALIZER_HH_ */
